#include "debugger/debugger.h"
#include "basic.h"
#include "command/commands.h"
#include "file.h"
#define DEBUGGING
int main(int argc, char **argv)
{
	init();
	generate();
	loader();
	selector();
	std::string file;
#ifdef DEBUGGING
	std::cin >> file;
#else
	if (argc == 1)
	{
		std::cout << "Fatal error:file not found.\n";
		exit(1);
	}
#endif
	std::ifstream test(file.c_str());
	if (!test.is_open())
	{
		std::cout << "Fatal error:file not found.\n";
		exit(1);
	}
	checkHeader(file.c_str());
	getHeader(file.c_str());
	loadImage(file.c_str());
#ifdef DEBUGGING
	while (1)
		debugger();
#else
	if (argc == 2)
		// Run file
		execute();
	else if (argc == 3)
	{
		// Debug file
		while (special_regs[Flag] & RUNNING)
			debugger();
	}
#endif
	return 0;
}